home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / pgm_tool / lu62 / trans.asm < prev    next >
Assembly Source File  |  1995-07-03  |  3KB  |  107 lines

  1. .MODEL LARGE
  2.        INCLUDE precod.inc
  3. .CODE
  4.        PUBLIC _trans
  5. _trans  proc
  6. ;**********************************************************
  7. ;*                                                        *
  8. ;*        Procedure for string translate.                 *
  9. ;*                                                        *
  10. ;* 1. Called : From "C" module -                          *
  11. ;*    int trans(target, source, length, Name)             *
  12. ;*    char far *target; - string "to",                    *
  13. ;*    char far *source; - string "from",                  *
  14. ;*    int  length;  - number of bytes for translation,    *
  15. ;*    int  Name; - name of trans. table.                  *
  16. ;*                                                        *
  17. ;* 2. Input : Parms are placed in stack.                  *
  18. ;*                                                        *
  19. ;* 3. Output: In the string pointed to by the "target"    *
  20. ;*    will be copied the "length" number of bytes         *
  21. ;*    which are translated according to the "Name" table. *                            *
  22. ;*                                                        *
  23. ;*                                                        *
  24. ;* CopyRight 1995. Nicholas Poljakov all rights reserved. *
  25. ;*                                                        *
  26. ;**********************************************************
  27.        push bp
  28.        mov  bp,sp
  29.        push bx
  30.        push cx
  31.        push dx
  32.        push di
  33.        push si
  34.        push es
  35.        push ds
  36. ;
  37.        mov  ax, seg _DATA
  38.        mov  ds, ax
  39.        mov  di, [bp + 6]
  40.        mov  dx, [bp + 8] ; save ES  es:di -> "to"
  41.        mov  es, dx
  42.        mov  si, [bp + 10]
  43.        mov  dx, [bp + 12] ; DS is in DX
  44.        mov  cx, [bp + 14]
  45.        mov  ax, [bp + 16]
  46. ;
  47.        cmp  ax,0    ; ASCIIalt to DKOI
  48.        jne  next00
  49.        lea  bx, es :T_A_D_1
  50.        jmp  tr_start
  51. next00:
  52.        cmp  ax,2    ; ASCIIm to DKOI
  53.        jne  next01
  54.        lea  bx, es :T_A_D_2
  55.        jmp  tr_start
  56. next01:
  57.        cmp  ax,4    ; ASCIIint to DKOI
  58.        jne  next02
  59.        lea  bx, es :T_A_D_3
  60.        jmp  tr_start
  61. next02:
  62.        cmp  ax,1    ; DKOI to ASCIIalt
  63.        jne  next03
  64.        lea  bx, es :T_D_A_1
  65.        jmp  tr_start
  66. next03:
  67.        cmp  ax,3    ; DKOI to ASCIIm
  68.        jne  next04
  69.        lea  bx, es :T_D_A_2
  70.        jmp  tr_start
  71. next04:
  72.        cmp  ax,5    ; DKOI to ASCIIint
  73.        jne  next05
  74.        lea  bx, es :T_D_A_3
  75.        jmp  tr_start
  76. next05:
  77.        mov  ax, 0ffh
  78.        jmp  tr_exit
  79. ;
  80. ;  DS:SI -> "from"; ES:DI -> "to"; BX -> trans. table;
  81. ;  CX - number of bytes
  82. ;
  83. tr_start:
  84.        cld
  85. tr:
  86.        push ds       ; save DS
  87.        mov  ds, dx   ; DS now points to source string segment
  88.        lodsb
  89.        pop  ds       ; restory DS for XLAT
  90.        xlat
  91.        stosb
  92.        loop tr
  93. ;
  94. tr_exit:
  95.        mov  ax, 0   ; return (0)
  96.        pop  ds
  97.        pop  es
  98.        pop  si
  99.        pop  di
  100.        pop  dx
  101.        pop  cx
  102.        pop  bx
  103.        pop  bp
  104.        RET
  105. _trans  endp
  106.        END
  107.